// 1. Option是标准库定义的一个枚举
/***
enum Option<T> {
    Some(T),
    None,
}
 */
// 2. 使用方法
fn main() {
    let some_number = Some(5);
    println!("some_number = {:?}",some_number);
    let some_string = Some(String::from("a string"));
    println!("some_string = {:?}",some_string);
    let absent_number: Option<i32> = None;
    println!("absent_number = {:?}",absent_number);

    let x: i32 = 5;
    let y: Option<i32> = Some(5);
    let mut temp = 0;
    match y {
        Some(i) => {temp = i}
        None => {println!("None")}
    }
    let sum = x + temp;
    println!("{}", sum);

    let i = Some(5);
    let resul = plus_one(i);
    match resul {
        Some(i) => {println!("i = {}", i)}
        None => {println!("None")}
    }
}
fn plus_one(x: Option<i32>) -> Option<i32> {
    match x {
        None => {None}
        Some(x) => {Some(x+1)}
    }
}
